package com.wwd.movie.website.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.wwd.movie.common.AjaxResult;
import com.wwd.movie.website.domain.entity.MovieBanner;
import com.wwd.movie.website.mapper.MovieBannerMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/movieBanner")
@RequiredArgsConstructor
public class MovieBannerController {

    private final MovieBannerMapper movieBannerMapper;


    @GetMapping("/list")
    public AjaxResult getMovieBannerList() {
        return AjaxResult.success(movieBannerMapper.selectList(
                Wrappers.<MovieBanner>lambdaQuery()
                        .orderByAsc(MovieBanner::getSort) // 按 sort 升序排列
                        .orderByDesc(MovieBanner::getCreateTime) // 如果 sort 相同，再按创建时间倒序
        ));
    }
}
